/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package yoga.gui;

import java.awt.Dialog;
import java.awt.Polygon;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JFrame;

/**
 *
 * @author Yogev Montekyo
 */
public class JFramePolygonFactory
{

    public enum FrameModes
    {
        ExitOnClose,
        HideOnClose;
    }
    public static JFrame getFrameWithPolygon(Polygon polygon, String text, FrameModes frameMode)
    {
        JFrame frame = new JFrame("Polygon Viewer");
        JPanelPolygonVisualization polygonPanel = new JPanelPolygonVisualization();
        polygonPanel.setPolygon(polygon, text);
        frame.getContentPane().add(polygonPanel);
        frame.setSize(640, 480);
        if (frameMode.equals(FrameModes.ExitOnClose)) {
            frame.addWindowListener(new WindowAdapter()
            {
                @Override
                public void windowClosing(WindowEvent e)
                {
                    System.exit(0);
                }
            });
        }        
        return frame;

    }
}
